package com.jz.netthings.netty.server;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import org.springframework.stereotype.Service;

import java.nio.charset.Charset;

@Service("nettyZxdcOutBoundHandler")
@ChannelHandler.Sharable
public class NettyZxdcOutBoundHandler extends ChannelOutboundHandlerAdapter {


    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {

//        System.out.println("NettyZxdcOutBoundHandler   write ： "+((ByteBuf)msg).toString(Charset.defaultCharset()));

        ctx.write(msg, promise);
    }
}
